package com.jame.basics.thread.thread_pond;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author : Jame
 * @date : 2021-01-14 20:47
 **/
public class ThreadPondTest {
    public static void main(String[] args) {
        //创建一个可伸缩线程池
        Executors.newCachedThreadPool();
        //单个线程
        ExecutorService executor = Executors.newSingleThreadExecutor();
        //创建一个固定大小的线程池
        Executors.newFixedThreadPool(5);
        /**
         * 这3个本质都是调用ThreadPoolExecutor来创建线程
         */

        try {
            executor.execute(()->{
                System.out.println("sss");
            });
        } finally {
            executor.shutdown();
        }


    }
}
